home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-38.z / lispref.info-38
Encoding:
GNU Info File  |  1998-05-21  |  49.1 KB  |  1,233 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Time Conversion,  Next: Timers,  Prev: Time of Day,  Up: System Interface
  48.  
  49. Time Conversion
  50. ===============
  51.  
  52.    These functions convert time values (lists of two or three integers)
  53. to strings or to calendrical information.  There is also a function to
  54. convert calendrical information to a time value.  You can get time
  55. values from the functions `current-time' (*note Time of Day::.) and
  56. `file-attributes' (*note File Attributes::.).
  57.  
  58.  - Function: format-time-string FORMAT-STRING TIME
  59.      This function converts TIME to a string according to
  60.      FORMAT-STRING.  The argument FORMAT-STRING may contain
  61.      `%'-sequences which say to substitute parts of the time.  Here is a
  62.      table of what the `%'-sequences mean:
  63.  
  64.     `%a'
  65.           This stands for the abbreviated name of the day of week.
  66.  
  67.     `%A'
  68.           This stands for the full name of the day of week.
  69.  
  70.     `%b'
  71.           This stands for the abbreviated name of the month.
  72.  
  73.     `%B'
  74.           This stands for the full name of the month.
  75.  
  76.     `%c'
  77.           This is a synonym for `%x %X'.
  78.  
  79.     `%C'
  80.           This has a locale-specific meaning.  In the default locale
  81.           (named C), it is equivalent to `%A, %B %e, %Y'.
  82.  
  83.     `%d'
  84.           This stands for the day of month, zero-padded.
  85.  
  86.     `%D'
  87.           This is a synonym for `%m/%d/%y'.
  88.  
  89.     `%e'
  90.           This stands for the day of month, blank-padded.
  91.  
  92.     `%h'
  93.           This is a synonym for `%b'.
  94.  
  95.     `%H'
  96.           This stands for the hour (00-23).
  97.  
  98.     `%I'
  99.           This stands for the hour (00-12).
  100.  
  101.     `%j'
  102.           This stands for the day of the year (001-366).
  103.  
  104.     `%k'
  105.           This stands for the hour (0-23), blank padded.
  106.  
  107.     `%l'
  108.           This stands for the hour (1-12), blank padded.
  109.  
  110.     `%m'
  111.           This stands for the month (01-12).
  112.  
  113.     `%M'
  114.           This stands for the minute (00-59).
  115.  
  116.     `%n'
  117.           This stands for a newline.
  118.  
  119.     `%p'
  120.           This stands for `AM' or `PM', as appropriate.
  121.  
  122.     `%r'
  123.           This is a synonym for `%I:%M:%S %p'.
  124.  
  125.     `%R'
  126.           This is a synonym for `%H:%M'.
  127.  
  128.     `%S'
  129.           This stands for the seconds (00-60).
  130.  
  131.     `%t'
  132.           This stands for a tab character.
  133.  
  134.     `%T'
  135.           This is a synonym for `%H:%M:%S'.
  136.  
  137.     `%U'
  138.           This stands for the week of the year (01-52), assuming that
  139.           weeks start on Sunday.
  140.  
  141.     `%w'
  142.           This stands for the numeric day of week (0-6).  Sunday is day
  143.           0.
  144.  
  145.     `%W'
  146.           This stands for the week of the year (01-52), assuming that
  147.           weeks start on Monday.
  148.  
  149.     `%x'
  150.           This has a locale-specific meaning.  In the default locale
  151.           (named C), it is equivalent to `%D'.
  152.  
  153.     `%X'
  154.           This has a locale-specific meaning.  In the default locale
  155.           (named C), it is equivalent to `%T'.
  156.  
  157.     `%y'
  158.           This stands for the year without century (00-99).
  159.  
  160.     `%Y'
  161.           This stands for the year with century.
  162.  
  163.     `%Z'
  164.           This stands for the time zone abbreviation.
  165.  
  166.  - Function: decode-time TIME
  167.      This function converts a time value into calendrical information.
  168.      The return value is a list of nine elements, as follows:
  169.  
  170.           (SECONDS MINUTES HOUR DAY MONTH YEAR DOW DST ZONE)
  171.  
  172.      Here is what the elements mean:
  173.  
  174.     SEC
  175.           The number of seconds past the minute, as an integer between
  176.           0 and 59.
  177.  
  178.     MINUTE
  179.           The number of minutes past the hour, as an integer between 0
  180.           and 59.
  181.  
  182.     HOUR
  183.           The hour of the day, as an integer between 0 and 23.
  184.  
  185.     DAY
  186.           The day of the month, as an integer between 1 and 31.
  187.  
  188.     MONTH
  189.           The month of the year, as an integer between 1 and 12.
  190.  
  191.     YEAR
  192.           The year, an integer typically greater than 1900.
  193.  
  194.     DOW
  195.           The day of week, as an integer between 0 and 6, where 0
  196.           stands for Sunday.
  197.  
  198.     DST
  199.           `t' if daylight savings time is effect, otherwise `nil'.
  200.  
  201.     ZONE
  202.           An integer indicating the time zone, as the number of seconds
  203.           east of Greenwich.
  204.  
  205.      Note that Common Lisp has different meanings for DOW and ZONE.
  206.  
  207.  - Function: encode-time SECONDS MINUTES HOUR DAY MONTH YEAR &optional
  208.           ZONE
  209.      This function is the inverse of `decode-time'.  It converts seven
  210.      items of calendrical data into a time value.  For the meanings of
  211.      the arguments, see the table above under `decode-time'.
  212.  
  213.      Year numbers less than 100 are treated just like other year
  214.      numbers.  If you want them to stand for years above 1900, you must
  215.      alter them yourself before you call `encode-time'.
  216.  
  217.      The optional argument ZONE defaults to the current time zone and
  218.      its daylight savings time rules.  If specified, it can be either a
  219.      list (as you would get from `current-time-zone') or an integer (as
  220.      you would get from `decode-time').  The specified zone is used
  221.      without any further alteration for daylight savings time.
  222.  
  223. 
  224. File: lispref.info,  Node: Timers,  Next: Terminal Input,  Prev: Time Conversion,  Up: System Interface
  225.  
  226. Timers for Delayed Execution
  227. ============================
  228.  
  229.    You can set up a timer to call a function at a specified future time.
  230.  
  231.  - Function: add-timeout SECS FUNCTION OBJECT &optional RESIGNAL
  232.      This function adds a timeout, to be signaled after the timeout
  233.      period has elapsed.  SECS is a number of seconds, expressed as an
  234.      integer or a float.  FUNCTION will be called after that many
  235.      seconds have elapsed, with one argument, the given OBJECT.  If the
  236.      optional RESIGNAL argument is provided, then after this timeout
  237.      expires, `add-timeout' will automatically be called again with
  238.      RESIGNAL as the first argument.
  239.  
  240.      This function returns an object which is the "id" of this
  241.      particular timeout.  You can pass that object to `disable-timeout'
  242.      to turn off the timeout before it has been signalled.
  243.  
  244.      The number of seconds may be expressed as a floating-point number,
  245.      in which case some fractional part of a second will be used.
  246.      Caveat: the usable timeout granularity will vary from system to
  247.      system.
  248.  
  249.      Adding a timeout causes a timeout event to be returned by
  250.      `next-event', and the function will be invoked by
  251.      `dispatch-event', so if XEmacs is in a tight loop, the function
  252.      will not be invoked until the next call to sit-for or until the
  253.      return to top-level (the same is true of process filters).
  254.  
  255.      WARNING: if you are thinking of calling add-timeout from inside of
  256.      a callback function as a way of resignalling a timeout, think
  257.      again.  There is a race condition.  That's why the RESIGNAL
  258.      argument exists.
  259.  
  260.      (NOTE: In FSF Emacs, this function is called `run-at-time' and has
  261.      different semantics.)
  262.  
  263.  - Function: disable-timeout ID
  264.      Cancel the requested action for ID, which should be a value
  265.      previously returned by `add-timeout'.  This cancels the effect of
  266.      that call to `add-timeout'; the arrival of the specified time will
  267.      not cause anything special to happen.  (NOTE: In FSF Emacs, this
  268.      function is called `cancel-timer'.)
  269.  
  270. 
  271. File: lispref.info,  Node: Terminal Input,  Next: Terminal Output,  Prev: Timers,  Up: System Interface
  272.  
  273. Terminal Input
  274. ==============
  275.  
  276.    This section describes functions and variables for recording or
  277. manipulating terminal input.  See *Note Display::, for related
  278. functions.
  279.  
  280. * Menu:
  281.  
  282. * Input Modes::        Options for how input is processed.
  283. * Translating Input::   Low level conversion of some characters or events
  284.               into others.
  285. * Recording Input::    Saving histories of recent or all input events.
  286.  
  287. 
  288. File: lispref.info,  Node: Input Modes,  Next: Translating Input,  Up: Terminal Input
  289.  
  290. Input Modes
  291. -----------
  292.  
  293.  - Function: set-input-mode INTERRUPT FLOW META QUIT-CHAR
  294.      This function sets the mode for reading keyboard input.  If
  295.      INTERRUPT is non-null, then XEmacs uses input interrupts.  If it is
  296.      `nil', then it uses CBREAK mode.  When XEmacs communicates
  297.      directly with X, it ignores this argument and uses interrupts if
  298.      that is the way it knows how to communicate.
  299.  
  300.      If FLOW is non-`nil', then XEmacs uses XON/XOFF (`C-q', `C-s')
  301.      flow control for output to the terminal.  This has no effect except
  302.      in CBREAK mode.  *Note Flow Control::.
  303.  
  304.      The default setting is system dependent.  Some systems always use
  305.      CBREAK mode regardless of what is specified.
  306.  
  307.      The argument META controls support for input character codes above
  308.      127.  If META is `t', XEmacs converts characters with the 8th bit
  309.      set into Meta characters.  If META is `nil', XEmacs disregards the
  310.      8th bit; this is necessary when the terminal uses it as a parity
  311.      bit.  If META is neither `t' nor `nil', XEmacs uses all 8 bits of
  312.      input unchanged.  This is good for terminals using European 8-bit
  313.      character sets.
  314.  
  315.      If QUIT-CHAR is non-`nil', it specifies the character to use for
  316.      quitting.  Normally this character is `C-g'.  *Note Quitting::.
  317.  
  318.    The `current-input-mode' function returns the input mode settings
  319. XEmacs is currently using.
  320.  
  321.  - Function: current-input-mode
  322.      This function returns current mode for reading keyboard input.  It
  323.      returns a list, corresponding to the arguments of `set-input-mode',
  324.      of the form `(INTERRUPT FLOW META QUIT)' in which:
  325.     INTERRUPT
  326.           is non-`nil' when XEmacs is using interrupt-driven input.  If
  327.           `nil', Emacs is using CBREAK mode.
  328.  
  329.     FLOW
  330.           is non-`nil' if XEmacs uses XON/XOFF (`C-q', `C-s') flow
  331.           control for output to the terminal.  This value has no effect
  332.           unless INTERRUPT is non-`nil'.
  333.  
  334.     META
  335.           is `t' if XEmacs treats the eighth bit of input characters as
  336.           the meta bit; `nil' means XEmacs clears the eighth bit of
  337.           every input character; any other value means XEmacs uses all
  338.           eight bits as the basic character code.
  339.  
  340.     QUIT
  341.           is the character XEmacs currently uses for quitting, usually
  342.           `C-g'.
  343.  
  344. 
  345. File: lispref.info,  Node: Translating Input,  Next: Recording Input,  Prev: Input Modes,  Up: Terminal Input
  346.  
  347. Translating Input Events
  348. ------------------------
  349.  
  350.    This section describes features for translating input events into
  351. other input events before they become part of key sequences.
  352.  
  353.  - Variable: function-key-map
  354.      This variable holds a keymap that describes the character sequences
  355.      sent by function keys on an ordinary character terminal.  This
  356.      keymap uses the same data structure as other keymaps, but is used
  357.      differently: it specifies translations to make while reading
  358.      events.
  359.  
  360.      If `function-key-map' "binds" a key sequence K to a vector V, then
  361.      when K appears as a subsequence *anywhere* in a key sequence, it
  362.      is replaced with the events in V.
  363.  
  364.      For example, VT100 terminals send `<ESC> O P' when the keypad PF1
  365.      key is pressed.  Therefore, we want XEmacs to translate that
  366.      sequence of events into the single event `pf1'.  We accomplish
  367.      this by "binding" `<ESC> O P' to `[pf1]' in `function-key-map',
  368.      when using a VT100.
  369.  
  370.      Thus, typing `C-c <PF1>' sends the character sequence `C-c <ESC> O
  371.      P'; later the function `read-key-sequence' translates this back
  372.      into `C-c <PF1>', which it returns as the vector `[?\C-c pf1]'.
  373.  
  374.      Entries in `function-key-map' are ignored if they conflict with
  375.      bindings made in the minor mode, local, or global keymaps.  The
  376.      intent is that the character sequences that function keys send
  377.      should not have command bindings in their own right.
  378.  
  379.      The value of `function-key-map' is usually set up automatically
  380.      according to the terminal's Terminfo or Termcap entry, but
  381.      sometimes those need help from terminal-specific Lisp files.
  382.      XEmacs comes with terminal-specific files for many common
  383.      terminals; their main purpose is to make entries in
  384.      `function-key-map' beyond those that can be deduced from Termcap
  385.      and Terminfo.  *Note Terminal-Specific::.
  386.  
  387.      Emacs versions 18 and earlier used totally different means of
  388.      detecting the character sequences that represent function keys.
  389.  
  390.  - Variable: key-translation-map
  391.      This variable is another keymap used just like `function-key-map'
  392.      to translate input events into other events.  It differs from
  393.      `function-key-map' in two ways:
  394.  
  395.         * `key-translation-map' goes to work after `function-key-map' is
  396.           finished; it receives the results of translation by
  397.           `function-key-map'.
  398.  
  399.         * `key-translation-map' overrides actual key bindings.
  400.  
  401.      The intent of `key-translation-map' is for users to map one
  402.      character set to another, including ordinary characters normally
  403.      bound to `self-insert-command'.
  404.  
  405.    You can use `function-key-map' or `key-translation-map' for more
  406. than simple aliases, by using a function, instead of a key sequence, as
  407. the "translation" of a key.  Then this function is called to compute
  408. the translation of that key.
  409.  
  410.    The key translation function receives one argument, which is the
  411. prompt that was specified in `read-key-sequence'--or `nil' if the key
  412. sequence is being read by the editor command loop.  In most cases you
  413. can ignore the prompt value.
  414.  
  415.    If the function reads input itself, it can have the effect of
  416. altering the event that follows.  For example, here's how to define
  417. `C-c h' to turn the character that follows into a Hyper character:
  418.  
  419.      (defun hyperify (prompt)
  420.        (let ((e (read-event)))
  421.          (vector (if (numberp e)
  422.                      (logior (lsh 1 20) e)
  423.                    (if (memq 'hyper (event-modifiers e))
  424.                        e
  425.                      (add-event-modifier "H-" e))))))
  426.      
  427.      (defun add-event-modifier (string e)
  428.        (let ((symbol (if (symbolp e) e (car e))))
  429.          (setq symbol (intern (concat string
  430.                                       (symbol-name symbol))))
  431.          (if (symbolp e)
  432.              symbol
  433.            (cons symbol (cdr e)))))
  434.      
  435.      (define-key function-key-map "\C-ch" 'hyperify)
  436.  
  437.    The `iso-transl' library uses this feature to provide a way of
  438. inputting non-ASCII Latin-1 characters.
  439.  
  440. 
  441. File: lispref.info,  Node: Recording Input,  Prev: Translating Input,  Up: Terminal Input
  442.  
  443. Recording Input
  444. ---------------
  445.  
  446.  - Function: recent-keys
  447.      This function returns a vector containing the last 100 input events
  448.      from the keyboard or mouse.  All input events are included,
  449.      whether or not they were used as parts of key sequences.  Thus,
  450.      you always get the last 100 inputs, not counting keyboard macros.
  451.      (Events from keyboard macros are excluded because they are less
  452.      interesting for debugging; it should be enough to see the events
  453.      that invoked the macros.)
  454.  
  455.  - Command: open-dribble-file FILENAME
  456.      This function opens a "dribble file" named FILENAME.  When a
  457.      dribble file is open, each input event from the keyboard or mouse
  458.      (but not those from keyboard macros) is written in that file.  A
  459.      non-character event is expressed using its printed representation
  460.      surrounded by `<...>'.
  461.  
  462.      You close the dribble file by calling this function with an
  463.      argument of `nil'.
  464.  
  465.      This function is normally used to record the input necessary to
  466.      trigger an XEmacs bug, for the sake of a bug report.
  467.  
  468.           (open-dribble-file "~/dribble")
  469.                => nil
  470.  
  471.    See also the `open-termscript' function (*note Terminal Output::.).
  472.  
  473. 
  474. File: lispref.info,  Node: Terminal Output,  Next: Flow Control,  Prev: Terminal Input,  Up: System Interface
  475.  
  476. Terminal Output
  477. ===============
  478.  
  479.    The terminal output functions send output to the terminal or keep
  480. track of output sent to the terminal.  The function `device-baud-rate'
  481. tells you what XEmacs thinks is the output speed of the terminal.
  482.  
  483.  - Function: device-baud-rate &optional DEVICE
  484.      This function's value is the output speed of the terminal
  485.      associated with DEVICE, as far as XEmacs knows.  DEVICE defaults
  486.      to the selected device (usually the only device) if omitted.
  487.      Changing this value does not change the speed of actual data
  488.      transmission, but the value is used for calculations such as
  489.      padding.  This value has no effect for window-system devices.
  490.      (This is different in FSF Emacs, where the baud rate also affects
  491.      decisions about whether to scroll part of the screen or repaint,
  492.      even when using a window system.)
  493.  
  494.      The value is measured in bits per second.
  495.  
  496.    XEmacs attempts to automatically initialize the baud rate by querying
  497. the terminal.  If you are running across a network, however, and
  498. different parts of the network work are at different baud rates, the
  499. value returned by XEmacs may be different from the value used by your
  500. local terminal.  Some network protocols communicate the local terminal
  501. speed to the remote machine, so that XEmacs and other programs can get
  502. the proper value, but others do not.  If XEmacs has the wrong value, it
  503. makes decisions that are less than optimal.  To fix the problem, use
  504. `set-device-baud-rate'.
  505.  
  506.  - Function: set-device-baud-rate &optional DEVICE
  507.      This function sets the output speed of DEVICE.  See
  508.      `device-baud-rate'.  DEVICE defaults to the selected device
  509.      (usually the only device) if omitted.
  510.  
  511.  - Function: send-string-to-terminal CHAR-OR-STRING &optional STDOUT-P
  512.           DEVICE
  513.      This function sends CHAR-OR-STRING to the terminal without
  514.      alteration.  Control characters in CHAR-OR-STRING have
  515.      terminal-dependent effects.
  516.  
  517.      If DEVICE is `nil', this function writes to XEmacs's stderr, or to
  518.      stdout if STDOUT-P is non-`nil'.  Otherwise, DEVICE should be a
  519.      tty or stream device, and the function writes to the device's
  520.      normal or error output, according to STDOUT-P.
  521.  
  522.      One use of this function is to define function keys on terminals
  523.      that have downloadable function key definitions.  For example,
  524.      this is how on certain terminals to define function key 4 to move
  525.      forward four characters (by transmitting the characters `C-u C-f'
  526.      to the computer):
  527.  
  528.           (send-string-to-terminal "\eF4\^U\^F")
  529.                => nil
  530.  
  531.  - Command: open-termscript FILENAME
  532.      This function is used to open a "termscript file" that will record
  533.      all the characters sent by XEmacs to the terminal. (If there are
  534.      multiple tty or stream devices, all characters sent to all such
  535.      devices are recorded.) The funcion returns `nil'.  Termscript
  536.      files are useful for investigating problems where XEmacs garbles
  537.      the screen, problems that are due to incorrect Termcap entries or
  538.      to undesirable settings of terminal options more often than to
  539.      actual XEmacs bugs.  Once you are certain which characters were
  540.      actually output, you can determine reliably whether they
  541.      correspond to the Termcap specifications in use.
  542.  
  543.      A `nil' value for FILENAME stops recording terminal output.
  544.  
  545.      See also `open-dribble-file' in *Note Terminal Input::.
  546.  
  547.           (open-termscript "../junk/termscript")
  548.                => nil
  549.  
  550. 
  551. File: lispref.info,  Node: Flow Control,  Next: Batch Mode,  Prev: Terminal Output,  Up: System Interface
  552.  
  553. Flow Control
  554. ============
  555.  
  556.    This section attempts to answer the question "Why does XEmacs choose
  557. to use flow-control characters in its command character set?"  For a
  558. second view on this issue, read the comments on flow control in the
  559. `emacs/INSTALL' file from the distribution; for help with Termcap
  560. entries and DEC terminal concentrators, see `emacs/etc/TERMS'.
  561.  
  562.    At one time, most terminals did not need flow control, and none used
  563. `C-s' and `C-q' for flow control.  Therefore, the choice of `C-s' and
  564. `C-q' as command characters was uncontroversial.  XEmacs, for economy
  565. of keystrokes and portability, used nearly all the ASCII control
  566. characters, with mnemonic meanings when possible; thus, `C-s' for
  567. search and `C-q' for quote.
  568.  
  569.    Later, some terminals were introduced which required these characters
  570. for flow control.  They were not very good terminals for full-screen
  571. editing, so XEmacs maintainers did not pay attention.  In later years,
  572. flow control with `C-s' and `C-q' became widespread among terminals,
  573. but by this time it was usually an option.  And the majority of users,
  574. who can turn flow control off, were unwilling to switch to less
  575. mnemonic key bindings for the sake of flow control.
  576.  
  577.    So which usage is "right", XEmacs's or that of some terminal and
  578. concentrator manufacturers?  This question has no simple answer.
  579.  
  580.    One reason why we are reluctant to cater to the problems caused by
  581. `C-s' and `C-q' is that they are gratuitous.  There are other
  582. techniques (albeit less common in practice) for flow control that
  583. preserve transparency of the character stream.  Note also that their use
  584. for flow control is not an official standard.  Interestingly, on the
  585. model 33 teletype with a paper tape punch (which is very old), `C-s'
  586. and `C-q' were sent by the computer to turn the punch on and off!
  587.  
  588.    As X servers and other window systems replace character-only
  589. terminals, this problem is gradually being cured.  For the mean time,
  590. XEmacs provides a convenient way of enabling flow control if you want
  591. it: call the function `enable-flow-control'.
  592.  
  593.  - Function: enable-flow-control
  594.      This function enables use of `C-s' and `C-q' for output flow
  595.      control, and provides the characters `C-\' and `C-^' as aliases
  596.      for them using `keyboard-translate-table' (*note Translating
  597.      Input::.).
  598.  
  599.    You can use the function `enable-flow-control-on' in your `.emacs'
  600. file to enable flow control automatically on certain terminal types.
  601.  
  602.  - Function: enable-flow-control-on &rest TERMTYPES
  603.      This function enables flow control, and the aliases `C-\' and
  604.      `C-^', if the terminal type is one of TERMTYPES.  For example:
  605.  
  606.           (enable-flow-control-on "vt200" "vt300" "vt101" "vt131")
  607.  
  608.    Here is how `enable-flow-control' does its job:
  609.  
  610.   1. It sets CBREAK mode for terminal input, and tells the operating
  611.      system to handle flow control, with `(set-input-mode nil t)'.
  612.  
  613.   2. It sets up `keyboard-translate-table' to translate `C-\' and `C-^'
  614.      into `C-s' and `C-q'.  Except at its very lowest level, XEmacs
  615.      never knows that the characters typed were anything but `C-s' and
  616.      `C-q', so you can in effect type them as `C-\' and `C-^' even when
  617.      they are input for other commands.  *Note Translating Input::.
  618.  
  619.    If the terminal is the source of the flow control characters, then
  620. once you enable kernel flow control handling, you probably can make do
  621. with less padding than normal for that terminal.  You can reduce the
  622. amount of padding by customizing the Termcap entry.  You can also
  623. reduce it by setting `baud-rate' to a smaller value so that XEmacs uses
  624. a smaller speed when calculating the padding needed.  *Note Terminal
  625. Output::.
  626.  
  627. 
  628. File: lispref.info,  Node: Batch Mode,  Prev: Flow Control,  Up: System Interface
  629.  
  630. Batch Mode
  631. ==========
  632.  
  633.    The command line option `-batch' causes XEmacs to run
  634. noninteractively.  In this mode, XEmacs does not read commands from the
  635. terminal, it does not alter the terminal modes, and it does not expect
  636. to be outputting to an erasable screen.  The idea is that you specify
  637. Lisp programs to run; when they are finished, XEmacs should exit.  The
  638. way to specify the programs to run is with `-l FILE', which loads the
  639. library named FILE, and `-f FUNCTION', which calls FUNCTION with no
  640. arguments.
  641.  
  642.    Any Lisp program output that would normally go to the echo area,
  643. either using `message' or using `prin1', etc., with `t' as the stream,
  644. goes instead to XEmacs's standard error descriptor when in batch mode.
  645. Thus, XEmacs behaves much like a noninteractive application program.
  646. (The echo area output that XEmacs itself normally generates, such as
  647. command echoing, is suppressed entirely.)
  648.  
  649.  - Function: noninteractive
  650.      This function returns non-`nil' when XEmacs is running in batch
  651.      mode.
  652.  
  653.  - Variable: noninteractive
  654.      This variable is non-`nil' when XEmacs is running in batch mode.
  655.      Setting this variable to `nil', however, will not change whether
  656.      XEmacs is running in batch mode, and will not change the return
  657.      value of the `noninteractive' function.
  658.  
  659. 
  660. File: lispref.info,  Node: X-Windows,  Next: ToolTalk Support,  Prev: System Interface,  Up: Top
  661.  
  662. Functions Specific to the X Window System
  663. *****************************************
  664.  
  665.    XEmacs provides the concept of "devices", which generalizes
  666. connections to an X server, a TTY device, etc.  Most information about
  667. an X server that XEmacs is connected to can be determined through
  668. general console and device functions.  *Note Consoles and Devices::.
  669. However, there are some features of the X Window System that do not
  670. generalize well, and they are covered specially here.
  671.  
  672. * Menu:
  673.  
  674. * X Selections::        Transferring text to and from other X clients.
  675. * X Server::            Information about the X server connected to
  676.                   a particular device.
  677. * X Miscellaneous::             Other X-specific functions and variables.
  678.  
  679. 
  680. File: lispref.info,  Node: X Selections,  Next: X Server,  Up: X-Windows
  681.  
  682. X Selections
  683. ============
  684.  
  685.    The X server records a set of "selections" which permit transfer of
  686. data between application programs.  The various selections are
  687. distinguished by "selection types", represented in XEmacs by symbols.
  688. X clients including XEmacs can read or set the selection for any given
  689. type.
  690.  
  691.  - Function: x-own-selection DATA &optional TYPE
  692.      This function sets a "selection" in the X server.  It takes two
  693.      arguments: a value, DATA, and the selection type TYPE to assign it
  694.      to.  DATA may be a string, a cons of two markers, or an extent.
  695.      In the latter cases, the selection is considered to be the text
  696.      between the markers, or between the extent's endpoints.
  697.  
  698.      Each possible TYPE has its own selection value, which changes
  699.      independently.  The usual values of TYPE are `PRIMARY' and
  700.      `SECONDARY'; these are symbols with upper-case names, in accord
  701.      with X Windows conventions.  The default is `PRIMARY'.
  702.  
  703.      (In FSF Emacs, this function is called `x-set-selection' and takes
  704.      different arguments.)
  705.  
  706.  - Function: x-get-selection
  707.      This function accesses selections set up by XEmacs or by other X
  708.      clients.  It returns the value of the current primary selection.
  709.  
  710.  - Function: x-disown-selection &optional SECONDARY-P
  711.      Assuming we own the selection, this function disowns it.  If
  712.      SECONDARY-P is non-`nil', the secondary selection instead of the
  713.      primary selection is discarded.
  714.  
  715.    The X server also has a set of numbered "cut buffers" which can
  716. store text or other data being moved between applications.  Cut buffers
  717. are considered obsolete, but XEmacs supports them for the sake of X
  718. clients that still use them.
  719.  
  720.  - Function: x-get-cutbuffer &optional N
  721.      This function returns the contents of cut buffer number N. (This
  722.      function is called `x-get-cut-buffer' in FSF Emacs.)
  723.  
  724.  - Function: x-store-cutbuffer STRING
  725.      This function stores STRING into the first cut buffer (cut buffer
  726.      0), moving the other values down through the series of cut buffers,
  727.      kill-ring-style. (This function is called `x-set-cut-buffer' in FSF
  728.      Emacs.)
  729.  
  730. 
  731. File: lispref.info,  Node: X Server,  Next: X Miscellaneous,  Prev: X Selections,  Up: X-Windows
  732.  
  733. X Server
  734. ========
  735.  
  736.    This section describes how to access and change the overall status of
  737. the X server XEmacs is using.
  738.  
  739. * Menu:
  740.  
  741. * Resources::            Getting resource values from the server.
  742. * Server Data::            Getting info about the X server.
  743. * Grabs::            Restricting access to the server by other apps.
  744.  
  745. 
  746. File: lispref.info,  Node: Resources,  Next: Server Data,  Up: X Server
  747.  
  748. Resources
  749. ---------
  750.  
  751.  - Function: default-x-device
  752.      This function return the default X device for resourcing.  This is
  753.      the first-created X device that still exists.
  754.  
  755.  - Function: x-get-resource NAME CLASS TYPE &optional LOCALE DEVICE
  756.           NOERROR
  757.      This function retrieves a resource value from the X resource
  758.      manager.
  759.  
  760.         * The first arg is the name of the resource to retrieve, such as
  761.           `"font"'.
  762.  
  763.         * The second arg is the class of the resource to retrieve, like
  764.           `"Font"'.
  765.  
  766.         * The third arg should be one of the symbols `string',
  767.           `integer', `natnum', or `boolean', specifying the type of
  768.           object that the database is searched for.
  769.  
  770.         * The fourth arg is the locale to search for the resources on,
  771.           and can currently be a a buffer, a frame, a device, or the
  772.           symbol `global'.  If omitted, it defaults to `global'.
  773.  
  774.         * The fifth arg is the device to search for the resources on.
  775.           (The resource database for a particular device is constructed
  776.           by combining non-device- specific resources such any
  777.           command-line resources specified and any app-defaults files
  778.           found [or the fallback resources supplied by XEmacs, if no
  779.           app-defaults file is found] with device-specific resources
  780.           such as those supplied using `xrdb'.) If omitted, it defaults
  781.           to the device of LOCALE, if a device can be derived (i.e. if
  782.           LOCALE is a frame or device), and otherwise defaults to the
  783.           value of `default-x-device'.
  784.  
  785.         * The sixth arg NOERROR, if non-`nil', means do not signal an
  786.           error if a bogus resource specification was retrieved (e.g.
  787.           if a non-integer was given when an integer was requested).
  788.           In this case, a warning is issued instead.
  789.  
  790.      The resource names passed to this function are looked up relative
  791.      to the locale.
  792.  
  793.      If you want to search for a subresource, you just need to specify
  794.      the resource levels in NAME and CLASS.  For example, NAME could be
  795.      `"modeline.attributeFont"', and CLASS `"Face.AttributeFont"'.
  796.  
  797.      Specifically,
  798.  
  799.        1. If LOCALE is a buffer, a call
  800.  
  801.                    `(x-get-resource "foreground" "Foreground" 'string SOME-BUFFER)'
  802.  
  803.           is an interface to a C call something like
  804.  
  805.                    `XrmGetResource (db, "xemacs.buffer.BUFFER-NAME.foreground",
  806.                            "Emacs.EmacsLocaleType.EmacsBuffer.Foreground",
  807.                            "String");'
  808.  
  809.        2. If LOCALE is a frame, a call
  810.  
  811.                    `(x-get-resource "foreground" "Foreground" 'string SOME-FRAME)'
  812.  
  813.           is an interface to a C call something like
  814.  
  815.                    `XrmGetResource (db, "xemacs.frame.FRAME-NAME.foreground",
  816.                            "Emacs.EmacsLocaleType.EmacsFrame.Foreground",
  817.                            "String");'
  818.  
  819.        3. If LOCALE is a device, a call
  820.  
  821.                    `(x-get-resource "foreground" "Foreground" 'string SOME-DEVICE)'
  822.  
  823.           is an interface to a C call something like
  824.  
  825.                    `XrmGetResource (db, "xemacs.device.DEVICE-NAME.foreground",
  826.                            "Emacs.EmacsLocaleType.EmacsDevice.Foreground",
  827.                            "String");'
  828.  
  829.        4. If LOCALE is the symbol `global', a call
  830.  
  831.                    `(x-get-resource "foreground" "Foreground" 'string 'global)'
  832.  
  833.           is an interface to a C call something like
  834.  
  835.                    `XrmGetResource (db, "xemacs.foreground",
  836.                            "Emacs.Foreground",
  837.                            "String");'
  838.  
  839.      Note that for `global', no prefix is added other than that of the
  840.      application itself; thus, you can use this locale to retrieve
  841.      arbitrary application resources, if you really want to.
  842.  
  843.      The returned value of this function is `nil' if the queried
  844.      resource is not found.  If TYPE is `string', a string is returned,
  845.      and if it is `integer', an integer is returned.  If TYPE is
  846.      `boolean', then the returned value is the list `(t)' for true,
  847.      `(nil)' for false, and is `nil' to mean "unspecified".
  848.  
  849.  - Function: x-put-resource RESOURCE-LINE &optional DEVICE
  850.      This function adds a resource to the resource database for DEVICE.
  851.      RESOURCE-LINE specifies the resource to add and should be a
  852.      standard resource specification.
  853.  
  854.  - Variable: x-emacs-application-class
  855.      This variable holds The X application class of the XEmacs process.
  856.      This controls, among other things, the name of the "app-defaults"
  857.      file that XEmacs will use.  For changes to this variable to take
  858.      effect, they must be made before the connection to the X server is
  859.      initialized, that is, this variable may only be changed before
  860.      XEmacs is dumped, or by setting it in the file
  861.      `lisp/term/x-win.el'.
  862.  
  863. 
  864. File: lispref.info,  Node: Server Data,  Next: Grabs,  Prev: Resources,  Up: X Server
  865.  
  866. Data about the X Server
  867. -----------------------
  868.  
  869.    This section describes functions and a variable that you can use to
  870. get information about the capabilities and origin of the X server
  871. corresponding to a particular device.  The device argument is generally
  872. optional and defaults to the selected device.
  873.  
  874.  - Function: x-server-version &optional DEVICE
  875.      This function returns the list of version numbers of the X server
  876.      DEVICE is on.  The returned value is a list of three integers: the
  877.      major and minor version numbers of the X protocol in use, and the
  878.      vendor-specific release number.
  879.  
  880.  - Function: x-server-vendor &optional DEVICE
  881.      This function returns the vendor supporting the X server DEVICE is
  882.      on.
  883.  
  884.  - Function: x-display-visual-class &optional DEVICE
  885.      This function returns the visual class of the display DEVICE is
  886.      on.  The value is one of the symbols `static-gray', `gray-scale',
  887.      `static-color', `pseudo-color', `true-color', and `direct-color'.
  888.      (Note that this is different from previous versions of XEmacs,
  889.      which returned `StaticGray', `GrayScale', etc.)
  890.  
  891. 
  892. File: lispref.info,  Node: Grabs,  Prev: Server Data,  Up: X Server
  893.  
  894. Restricting Access to the Server by Other Apps
  895. ----------------------------------------------
  896.  
  897.  - Function: x-grab-keyboard &optional DEVICE
  898.      This function grabs the keyboard on the given device (defaulting
  899.      to the selected one).  So long as the keyboard is grabbed, all
  900.      keyboard events will be delivered to XEmacs - it is not possible
  901.      for other X clients to eavesdrop on them.  Ungrab the keyboard
  902.      with `x-ungrab-keyboard' (use an `unwind-protect').  Returns `t'
  903.      if the grab was successful; `nil' otherwise.
  904.  
  905.  - Function: x-ungrab-keyboard &optional DEVICE
  906.      This function releases a keyboard grab made with `x-grab-keyboard'.
  907.  
  908.  - Function: x-grab-pointer &optional DEVICE CURSOR IGNORE-KEYBOARD
  909.      This function grabs the pointer and restricts it to its current
  910.      window.  If optional DEVICE argument is `nil', the selected device
  911.      will be used.  If optional CURSOR argument is non-`nil', change
  912.      the pointer shape to that until `x-ungrab-pointer' is called (it
  913.      should be an object returned by the `make-cursor' function).  If
  914.      the second optional argument IGNORE-KEYBOARD is non-`nil', ignore
  915.      all keyboard events during the grab.  Returns `t' if the grab is
  916.      successful, `nil' otherwise.
  917.  
  918.  - Function: x-ungrab-pointer &optional DEVICE
  919.      This function releases a pointer grab made with `x-grab-pointer'.
  920.      If optional first arg DEVICE is `nil' the selected device is used.
  921.      If it is `t' the pointer will be released on all X devices.
  922.  
  923. 
  924. File: lispref.info,  Node: X Miscellaneous,  Prev: X Server,  Up: X-Windows
  925.  
  926. Miscellaneous X Functions and Variables
  927. =======================================
  928.  
  929.  - Variable: x-bitmap-file-path
  930.      This variable holds a list of the directories in which X bitmap
  931.      files may be found.  If `nil', this is initialized from the
  932.      `"*bitmapFilePath"' resource.  This is used by the
  933.      `make-image-instance' function (however, note that if the
  934.      environment variable `XBMLANGPATH' is set, it is consulted first).
  935.  
  936.  - Variable: x-library-search-path
  937.      This variable holds the search path used by `read-color' to find
  938.      `rgb.txt'.
  939.  
  940.  - Function: x-valid-keysym-name-p KEYSYM
  941.      This function returns true if KEYSYM names a keysym that the X
  942.      library knows about.  Valid keysyms are listed in the files
  943.      `/usr/include/X11/keysymdef.h' and in `/usr/lib/X11/XKeysymDB', or
  944.      whatever the equivalents are on your system.
  945.  
  946.  - Function: x-window-id &optional FRAME
  947.      This function returns the ID of the X11 window.  This gives us a
  948.      chance to manipulate the Emacs window from within a different
  949.      program.  Since the ID is an unsigned long, we return it as a
  950.      string.
  951.  
  952.  - Variable: x-allow-sendevents
  953.      If non-`nil', synthetic events are allowed.  `nil' means they are
  954.      ignored.  Beware: allowing XEmacs to process SendEvents opens a
  955.      big security hole.
  956.  
  957.  - Function: x-debug-mode ARG &optional DEVICE
  958.      With a true arg, make the connection to the X server synchronous.
  959.      With false, make it asynchronous.  Synchronous connections are
  960.      much slower, but are useful for debugging. (If you get X errors,
  961.      make the connection synchronous, and use a debugger to set a
  962.      breakpoint on `x_error_handler'.  Your backtrace of the C stack
  963.      will now be useful.  In asynchronous mode, the stack above
  964.      `x_error_handler' isn't helpful because of buffering.)  If DEVICE
  965.      is not specified, the selected device is assumed.
  966.  
  967.      Calling this function is the same as calling the C function
  968.      `XSynchronize', or starting the program with the `-sync' command
  969.      line argument.
  970.  
  971.  - Variable: x-debug-events
  972.      If non-zero, debug information about events that XEmacs sees is
  973.      displayed.  Information is displayed on stderr.  Currently defined
  974.      values are:
  975.  
  976.         * 1 == non-verbose output
  977.  
  978.         * 2 == verbose output
  979.  
  980. 
  981. File: lispref.info,  Node: ToolTalk Support,  Next: Internationalization,  Prev: X-Windows,  Up: Top
  982.  
  983. ToolTalk Support
  984. ****************
  985.  
  986. * Menu:
  987.  
  988. * XEmacs ToolTalk API Summary::
  989. * Sending Messages::
  990. * Receiving Messages::
  991.  
  992. 
  993. File: lispref.info,  Node: XEmacs ToolTalk API Summary,  Next: Sending Messages,  Up: ToolTalk Support
  994.  
  995. XEmacs ToolTalk API Summary
  996. ===========================
  997.  
  998.    The XEmacs Lisp interface to ToolTalk is similar, at least in spirit,
  999. to the standard C ToolTalk API.  Only the message and pattern parts of
  1000. the API are supported at present; more of the API could be added if
  1001. needed.  The Lisp interface departs from the C API in a few ways:
  1002.  
  1003.    * ToolTalk is initialized automatically at XEmacs startup-time.
  1004.      Messages can only be sent other ToolTalk applications connected to
  1005.      the same X11 server that XEmacs is running on.
  1006.  
  1007.    * There are fewer entry points; polymorphic functions with keyword
  1008.      arguments are used instead.
  1009.  
  1010.    * The callback interface is simpler and marginally less functional.
  1011.      A single callback may be associated with a message or a pattern;
  1012.      the callback is specified with a Lisp symbol (the symbol should
  1013.      have a function binding).
  1014.  
  1015.    * The session attribute for messages and patterns is always
  1016.      initialized to the default session.
  1017.  
  1018.    * Anywhere a ToolTalk enum constant, e.g. `TT_SESSION', is valid, one
  1019.      can substitute the corresponding symbol, e.g. `'TT_SESSION'.  This
  1020.      simplifies building lists that represent messages and patterns.
  1021.  
  1022. 
  1023. File: lispref.info,  Node: Sending Messages,  Next: Receiving Messages,  Prev: XEmacs ToolTalk API Summary,  Up: ToolTalk Support
  1024.  
  1025. Sending Messages
  1026. ================
  1027.  
  1028. * Menu:
  1029.  
  1030. * Example of Sending Messages::
  1031. * Elisp Interface for Sending Messages::
  1032.  
  1033. 
  1034. File: lispref.info,  Node: Example of Sending Messages,  Next: Elisp Interface for Sending Messages,  Up: Sending Messages
  1035.  
  1036. Example of Sending Messages
  1037. ---------------------------
  1038.  
  1039.    Here's a simple example that sends a query to another application
  1040. and then displays its reply.  Both the query and the reply are stored
  1041. in the first argument of the message.
  1042.  
  1043.      (defun tooltalk-random-query-handler (msg)
  1044.        (let ((state (get-tooltalk-message-attribute msg 'state)))
  1045.          (cond
  1046.            ((eq state 'TT_HANDLED)
  1047.             (message (get-tooltalk-message-attribute msg arg_val 0)))
  1048.            ((memq state '(TT_FAILED TT_REJECTED))
  1049.             (message "Random query turns up nothing")))))
  1050.      
  1051.      (defvar random-query-message
  1052.        '(   class TT_REQUEST
  1053.             scope TT_SESSION
  1054.           address TT_PROCEDURE
  1055.                op "random-query"
  1056.              args '((TT_INOUT "?" "string"))
  1057.          callback tooltalk-random-query-handler))
  1058.      
  1059.      (let ((m (make-tooltalk-message random-query-message)))
  1060.        (send-tooltalk-message m))
  1061.  
  1062. 
  1063. File: lispref.info,  Node: Elisp Interface for Sending Messages,  Prev: Example of Sending Messages,  Up: Sending Messages
  1064.  
  1065. Elisp Interface for Sending Messages
  1066. ------------------------------------
  1067.  
  1068.  - Function: make-tooltalk-message ATTRIBUTES
  1069.      Create a ToolTalk message and initialize its attributes.  The
  1070.      value of ATTRIBUTES must be a list of alternating keyword/values,
  1071.      where keywords are symbols that name valid message attributes.
  1072.      For example:
  1073.  
  1074.             (make-tooltalk-message
  1075.               '(class TT_NOTICE
  1076.                 scope TT_SESSION
  1077.                 address TT_PROCEDURE
  1078.                 op "do-something"
  1079.                 args ("arg1" 12345 (TT_INOUT "arg3" "string"))))
  1080.  
  1081.      Values must always be strings, integers, or symbols that represent
  1082.      ToolTalk constants.  Attribute names are the same as those
  1083.      supported by `set-tooltalk-message-attribute', plus `args'.
  1084.  
  1085.      The value of `args' should be a list of message arguments where
  1086.      each message argument has the following form:
  1087.  
  1088.              `(mode [value [type]])' or just `value'
  1089.  
  1090.      Where MODE is one of `TT_IN', `TT_OUT', or `TT_INOUT' and TYPE is
  1091.      a string.  If TYPE isn't specified then `int' is used if VALUE is
  1092.      a number; otherwise `string' is used.  If TYPE is `string' then
  1093.      VALUE is converted to a string (if it isn't a string already) with
  1094.      `prin1-to-string'.  If only a value is specified then MODE
  1095.      defaults to `TT_IN'.  If MODE is `TT_OUT' then VALUE and TYPE
  1096.      don't need to be specified.  You can find out more about the
  1097.      semantics and uses of ToolTalk message arguments in chapter 4 of
  1098.      the `ToolTalk Programmer's Guide'.
  1099.  
  1100.  
  1101.  - Function: send-tooltalk-message MSG
  1102.      Send the message on its way.  Once the message has been sent it's
  1103.      almost always a good idea to get rid of it with
  1104.      `destroy-tooltalk-message'.
  1105.  
  1106.  
  1107.  - Function: return-tooltalk-message MSG &optional MODE
  1108.      Send a reply to this message.  The second argument can be `reply',
  1109.      `reject' or `fail'; the default is `reply'.  Before sending a
  1110.      reply, all message arguments whose mode is `TT_INOUT' or `TT_OUT'
  1111.      should have been filled in - see `set-tooltalk-message-attribute'.
  1112.  
  1113.  
  1114.  - Function: get-tooltalk-message-attribute MSG ATTRIBUTE &optional ARGN
  1115.      Returns the indicated ToolTalk message attribute.  Attributes are
  1116.      identified by symbols with the same name (underscores and all) as
  1117.      the suffix of the ToolTalk `tt_message_<attribute>' function that
  1118.      extracts the value.  String attribute values are copied and
  1119.      enumerated type values (except disposition) are converted to
  1120.      symbols; e.g. `TT_HANDLER' is `'TT_HANDLER', `uid' and `gid' are
  1121.      represented by fixnums (small integers), `opnum' is converted to a
  1122.      string, and `disposition' is converted to a fixnum.  We convert
  1123.      `opnum' (a C int) to a string (e.g. `123' => `"123"') because
  1124.      there's no guarantee that opnums will fit within the range of
  1125.      XEmacs Lisp integers.
  1126.  
  1127.      [TBD] Use the `plist' attribute instead of C API `user' attribute
  1128.      for user-defined message data.  To retrieve the value of a message
  1129.      property, specify the indicator for ARGN.  For example, to get the
  1130.      value of a property called `rflag', use
  1131.  
  1132.              (get-tooltalk-message-attribute msg 'plist 'rflag)
  1133.  
  1134.      To get the value of a message argument use one of the `arg_val'
  1135.      (strings), `arg_ival' (integers), or `arg_bval' (strings with
  1136.      embedded nulls), attributes.  For example, to get the integer
  1137.      value of the third argument:
  1138.  
  1139.              (get-tooltalk-message-attribute msg 'arg_ival 2)
  1140.  
  1141.      As you can see, argument numbers are zero-based.  The type of each
  1142.      arguments can be retrieved with the `arg_type' attribute; however
  1143.      ToolTalk doesn't define any semantics for the string value of
  1144.      `arg_type'.  Conventionally `string' is used for strings and `int'
  1145.      for 32 bit integers.  Note that XEmacs Lisp stores the lengths of
  1146.      strings explicitly (unlike C) so treating the value returned by
  1147.      `arg_bval' like a string is fine.
  1148.  
  1149.  
  1150.  - Function: set-tooltalk-message-attribute VALUE MSG ATTRIBUTE
  1151.           &optional ARGN
  1152.      Initialize one ToolTalk message attribute.
  1153.  
  1154.      Attribute names and values are the same as for
  1155.      `get-tooltalk-message-attribute'.  A property list is provided for
  1156.      user data (instead of the `user' message attribute); see
  1157.      `get-tooltalk-message-attribute'.
  1158.  
  1159.      Callbacks are handled slightly differently than in the C ToolTalk
  1160.      API.  The value of CALLBACK should be the name of a function of one
  1161.      argument.  It will be called each time the state of the message
  1162.      changes.  This is usually used to notice when the message's state
  1163.      has changed to `TT_HANDLED' (or `TT_FAILED'), so that reply
  1164.      argument values can be used.
  1165.  
  1166.      If one of the argument attributes is specified as `arg_val',
  1167.      `arg_ival', or `arg_bval', then ARGN must be the number of an
  1168.      already created argument.  Arguments can be added to a message
  1169.      with `add-tooltalk-message-arg'.
  1170.  
  1171.  
  1172.  - Function: add-tooltalk-message-arg MSG MODE TYPE &optional VALUE
  1173.      Append one new argument to the message.  MODE must be one of
  1174.      `TT_IN', `TT_INOUT', or `TT_OUT', TYPE must be a string, and VALUE
  1175.      can be a string or an integer.  ToolTalk doesn't define any
  1176.      semantics for TYPE, so only the participants in the protocol
  1177.      you're using need to agree what types mean (if anything).
  1178.      Conventionally `string' is used for strings and `int' for 32 bit
  1179.      integers.  Arguments can initialized by providing a value or with
  1180.      `set-tooltalk-message-attribute'; the latter is necessary if you
  1181.      want to initialize the argument with a string that can contain
  1182.      embedded nulls (use `arg_bval').
  1183.  
  1184.  
  1185.  - Function: create-tooltalk-message
  1186.      Create a new ToolTalk message.  The message's session attribute is
  1187.      initialized to the default session.  Other attributes can be
  1188.      intialized with `set-tooltalk-message-attribute'.
  1189.      `make-tooltalk-message' is the preferred way to create and
  1190.      initialize a message.
  1191.  
  1192.  
  1193.  - Function: destroy-tooltalk-message MSG
  1194.      Apply `tt_message_destroy' to the message.  It's not necessary to
  1195.      destroy messages after they've been processed by a message or
  1196.      pattern callback, the Lisp/ToolTalk callback machinery does this
  1197.      for you.
  1198.  
  1199. 
  1200. File: lispref.info,  Node: Receiving Messages,  Prev: Sending Messages,  Up: ToolTalk Support
  1201.  
  1202. Receiving Messages
  1203. ==================
  1204.  
  1205. * Menu:
  1206.  
  1207. * Example of Receiving Messages::
  1208. * Elisp Interface for Receiving Messages::
  1209.  
  1210. 
  1211. File: lispref.info,  Node: Example of Receiving Messages,  Next: Elisp Interface for Receiving Messages,  Up: Receiving Messages
  1212.  
  1213. Example of Receiving Messages
  1214. -----------------------------
  1215.  
  1216.    Here's a simple example of a handler for a message that tells XEmacs
  1217. to display a string in the mini-buffer area.  The message operation is
  1218. called `emacs-display-string'.  Its first (0th) argument is the string
  1219. to display.
  1220.  
  1221.      (defun tooltalk-display-string-handler (msg)
  1222.        (message (get-tooltalk-message-attribute msg 'arg_val 0)))
  1223.      
  1224.      (defvar display-string-pattern
  1225.        '(category TT_HANDLE
  1226.             scope TT_SESSION
  1227.                op "emacs-display-string"
  1228.          callback tooltalk-display-string-handler))
  1229.      
  1230.      (let ((p (make-tooltalk-pattern display-string-pattern)))
  1231.        (register-tooltalk-pattern p))
  1232.  
  1233.